using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Eve.API
{
    /// <summary>
    /// Represents detailed information about the skill that a character is currently training.
    /// </summary>
    /// <remarks>
    /// <para>
    /// The <b>SkillTraining</b> class represents detailed information about the skill that a character
    /// is currently training.
    /// </para>
    /// <para>
    /// If the <see cref="Eve.API.SkillTraining.SkillInTraining">SkillInTraining</see> value is <b>false</b>, then
    /// the character is not currently training a skill, and the values of all other properties is undefined.
    /// </para>
    /// </remarks>
    [Serializable]
    public class SkillTraining
    {
        private bool skillInTraining;
        private DateTime endTime;
        private DateTime startTime;
        private int skillTypeId;
        private int startingSkillPoints;
        private int destinationSkillPoints;
        private int trainingToLevel;

        /// <summary>
        /// Gets a value indicating whether a skill is currently being trained.
        /// </summary>
        /// <value>
        /// <b>true</b> if a skill is currently being trained; otherwise, <b>false</b>.
        /// </value>
        public bool SkillInTraining
        {
            get { return skillInTraining; }
        }
        /// <summary>
        /// Gets the date and time at which the skill training will be complete.
        /// </summary>
        /// <value>
        /// The Eve date and time at which the skill training will be complete.
        /// </value>
        /// <remarks>
        /// <note type="note">This time is not localized.  It represents game time.</note>
        /// </remarks>
        public DateTime EndTime
        {
            get { return endTime; }
        }
        /// <summary>
        /// Gets the date and time at which the skill training was started.
        /// </summary>
        /// <value>
        /// The Eve date and time at which the skill training was started.
        /// </value>
        /// <remarks>
        /// <note type="note">This time is not localized.  It represents game time.</note>
        /// </remarks>
        public DateTime StartTime
        {
            get { return startTime; }
        }
        /// <summary>
        /// Gets the type identifier for the skill being trained.
        /// </summary>
        /// <value>
        /// The Eve internal type identifier for the skill being trained.
        /// </value>
        /// <remarks>
        /// This value can be used with the results from the <see cref="Eve.API.EveAPI.GetSkillTree">EveAPI.GetSkillTree</see> method or the <b>Eve.Data</b> class library
        /// to get detailed information about the specific skill.
        /// </remarks>
        public int SkillTypeId
        {
            get { return skillTypeId; }
        }
        /// <summary>
        /// Gets the number of skill points that had been trained in this skill prior to training the current level.
        /// </summary>
        /// <value>
        /// The number of skill points that had been trained in this skill prior to training the current level.
        /// </value>
        public int StartingSkillPoints
        {
            get { return startingSkillPoints; }
        }
        /// <summary>
        /// Gets the number of skill points that will be trained in this skill when training is complete.
        /// </summary>
        /// <value>
        /// The number of skill points that will be trained in this skill when training is complete.
        /// </value>
        public int DestinationSkillPoints
        {
            get { return destinationSkillPoints; }
        }
        /// <summary>
        /// Gets the level to which this skill is being trained.
        /// </summary>
        /// <value>
        /// The level to which this skill is being trained.
        /// </value>
        public int TrainingToLevel
        {
            get { return trainingToLevel; }
        }

        internal SkillTraining(XmlElement st)
        {
            skillInTraining = int.Parse(st["skillInTraining"].InnerText) == 1;
            if (skillInTraining)
            {
                endTime = DateTime.Parse(st["trainingEndTime"].InnerText);
                startTime = DateTime.Parse(st["trainingStartTime"].InnerText);
                skillTypeId = int.Parse(st["trainingTypeID"].InnerText);
                startingSkillPoints = int.Parse(st["trainingStartSP"].InnerText);
                destinationSkillPoints = int.Parse(st["trainingDestinationSP"].InnerText);
                trainingToLevel = int.Parse(st["trainingToLevel"].InnerText);
            }
        }
    }
}
